<template>
  <ul class="todo-list">
    <!-- completed: 完成的类名 -->
    <li v-for="todo in list" :key="todo.id" :class="{ completed: todo.isDone }">
      <div class="view">
        <input
          :id="todo.id"
          v-model="todo.isDone"
          class="toggle"
          type="checkbox"
        />
        <label :for="todo.id">{{ todo.name }}</label>
        <button @click="delTodo(todo.id)" class="destroy"></button>
      </div>
    </li>
  </ul>
</template>

<script>
export default {
  props: {
    list: {
      type: Array,
      default: () => [],
    },
  },
  methods: {
    delTodo(id) {
      this.$emit("del-todo", id);
    },
  },
};
</script>